<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAgentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('agents', function (Blueprint $table) {
            $table->increments('id');
            $table->string('username')->default('')->comment('用户名');
            $table->string('name')->nullable()->comment('昵称');
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('password')->default('123456')->comment('登录密码');
            $table->decimal('balance')->default('0.00')->comment('账户余额');
            $table->decimal('withdraw')->default('0.00')->comment('已提现金额');
            $table->bigInteger('parent_id')->nullable()->comment('推荐人ID');
            $table->string('from_code')->nullable()->comment('注册使用的邀请码');
            $table->decimal('rake_back_rate')->default('0.00')->comment('返佣比例%');
            $table->decimal('withdraw_rate')->default('0.00')->comment('提现手续费%');
            $table->integer('deduct')->default(0)->comment('扣量');
            $table->integer('deduct_counter')->default(0)->comment('扣量计数器');
            $table->string('last_ip')->nullable()->comment('最后登录IP');
            $table->tinyInteger('state')->default('1')->comment('代理状态：1正常，0待审核，-1封禁');
            $table->string('remember_token')->nullable();
            $table->string('wechat')->nullable();
            $table->string('phone')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('agents');
    }
}
